package org.alanlau.rabbitmq.config;

import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * @author alan
 * @version 1.0
 * @date 2021/4/8 17:31
 */
@Component
public class MsgUuid implements MessagePostProcessor {
    @Override
    public Message postProcessMessage(Message message) throws AmqpException {
        String messageId = UUID.randomUUID().toString().replace("-", "");
        message.getMessageProperties().setMessageId(messageId);
        return message;
    }
}
